package org.ant.gui.panes.ACtextpanel;

import java.awt.Cursor;
import java.awt.Desktop;
import java.awt.Dimension;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.JButton;
import javax.swing.JLabel;

public class LineNumberLabel extends JLabel{
	private int num;
	private String errorMessage;

	public LineNumberLabel(int num) {
		this.num = num;
		this.errorMessage = null;

		this.setPreferredSize(new Dimension(LineNumberPanel.WIDTH,15));
		setHightlight(false);
		addMouseListener(new MouseAdapter() {
			public void mouseEntered(MouseEvent e) {
				setHightlight(true);
				setCursor(new Cursor(Cursor.HAND_CURSOR));
			}
			public void mouseExited(MouseEvent e) {
				setHightlight(false);
			}
			public void mouseClicked(MouseEvent e) {

			}
		});
	}

	private void setHightlight(boolean hightlight) {
		if (errorMessage==null){
			if (!hightlight)
				setText("<html><font color=blue>" + num);
			else
				setText("<html><font color=gray>" + num);
		}
	}

	public void setError(String error){
		setText("<html><font color=red>" + num);
		this.errorMessage = error;
		this.setToolTipText(error);
	}

	public void clearError(){
		this.errorMessage = null;
		setText("<html><font color=blue>" + num);
		this.setToolTipText("");
	}
}
